package com.tanhua.server.service;

import com.tanhua.commons.templates.HuanXinTemplate;
import com.tanhua.domain.vo.TodayBestVo;
import com.tanhua.dubbo.api.mongo.TanhuaApi;
import com.tanhua.server.Interceptor.UserHolder;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class TanhuaService {
    @Reference
    private TanhuaApi tanhuaApi;
    @Autowired
    private HuanXinTemplate huanXinTemplate;

    public ResponseEntity idLove(long id) {
        Boolean aBoolean = tanhuaApi.idLove(id, UserHolder.getUserId());
        if (aBoolean) {
            huanXinTemplate.contactUsers(UserHolder.getUserId(), id);
        }
        return ResponseEntity.ok(null);
    }

    public ResponseEntity idunLove(long id) {
        tanhuaApi.idunLove(id, UserHolder.getUserId());
        return ResponseEntity.ok(null);
    }


    public ResponseEntity<Object> get10RecommendUsers() {
        List<TodayBestVo> result = tanhuaApi.getRecommendations(UserHolder.getUserId(), 10);
        return ResponseEntity.ok(result);
    }
}
